{% extends "layout.html" %}

{% block css_m %}

{% endblock %}
{% block js_m %}

{% endblock %}

{% block content_body %}
    <div class="page-jumbotron center-block" style="width: 800px">
        <h1>查看回访</h1>
        <div class="container" style="margin-top: 0">
            <div class="row">
                <div class="col-md-10">
                    <h4>{{ customer_obj.name }}
                        <small> {{ customer_obj.get_sex_display }} {{ customer_obj.age }}岁</small>

                    </h4>

                </div>
                <div class="row">
                    <div class="col-md-6">
                        <table class="table table-striped table-hover" style="width: 400px">
                            <tr>
                                <td>联系方式</td>
                                <td>{{ customer_obj.phone }}</td>
                            </tr>
                            <tr>
                                <td>主要症状</td>
                                <td>{{ customer_obj.symptom }}</td>
                            </tr>
                            <tr>
                                <td>病史</td>
                                <td>{{ customer_obj.ill_date_period }}</td>
                            </tr>
                            <tr>
                                <td>状态</td>
                                <td>{{ test_obj.get_trail_or_bought_display }}</td>

                            </tr>


                        </table>
                    </div>
                    <div class="col-md-6">
                        <table class="table table-striped table-hover" style="width: 400px">
                            <tr>
                                <td>末次回访时间</td>
                                <td>{{ rv_obj.create_time }}</td>
                            </tr>
                            <tr>
                                <td>首次进店时间</td>
                                <td>{{ customer_obj.create_time }}</td>
                            </tr>

                            <tr>
                                <td>末次进店时间</td>
                                <td>{{ test_obj.test_date }}</td>
                            </tr>
                            <tr>
                                <td>满意度</td>
                                <td>{{ customer_obj.satisfaction }}</td>
                            </tr>


                        </table>
                    </div>
                </div>
                <div class="panel-body" style="width: 1000px">
                    <div class="panel panel-warning" id="p">
                        <div class="panel-heading">回访数据 <a class="btn btn-warning btn-xs" id="edit"
                                                           style="margin-left: 20px">编 辑</a><a class="btn btn-default btn-xs" href="/returning_visits/{{ customer_obj.pid }}/list.html/" style="margin-left: 3px">返 回</a></div>

                    </div>
                </div>
                <div class="panel-body hidden" id="form" style="width: 1000px">
                    <form method="post" novalidate>
                        {% csrf_token %}
                        {% for field in form_add %}

                            <div class="form-group">
                                <label>{{ field.label }}</label>
                                {{ field }}
                                <span class="error_msg">{{ field.errors.0 }}</span>
                            </div>


                        {% endfor %}

                        <button type="submit" class="btn btn-primary">提 交</button>
                        <a class="btn btn-default" id="cancel" href="#">取 消</a>
                    </form>

                </div>

            </div>
        </div>

    </div>










{% endblock %}

{% block content_bottom %}
    <script>
        $(document).ready(function () {
            var content = '<ul class="list-group">'
            $("#form").find('div').each(function (index, obj) {
                if (index && index < 2) {
                    content += "<li class=\"list-group-item\">" + $(obj).find('label').first().text() + "：</li><li class=\"list-group-item\">" + $(obj).find('input').first().val() + "</li>"
                }
            })
            content += "<li class=\"list-group-item\">客户反馈：</li><li class=\"list-group-item\">" + $("#id_feedback").val() + "</li>"
            content += "<li class=\"list-group-item\">回访总结：</li><li class=\"list-group-item\">" + $("#id_summary").val() + "</li>"
            $("#p").append(content)


        });
        $(function () {
            $("#edit").on("click", function () {
                $("#p").addClass("hidden");

                $("#form").removeClass("hidden");
                $("#form").find("div").first().addClass("hidden");
            });
            $("#cancel").on("click", function () {
                $("#p").removeClass("hidden");

                $("#form").addClass("hidden");

            })
        })

    </script>
{% endblock %}